package kevin.newmybatis.mybatis.session;

import kevin.newmybatis.mybatis.config.MyConfiguration;
import kevin.newmybatis.mybatis.executor.MyExecutor;

/**
 * mybatis核心类
 */
public class SqlSession {

    //实现加载mapper
    private MyConfiguration configuration;
    //执行sql
    private MyExecutor executor;


    public SqlSession(MyConfiguration configuration, MyExecutor executor) {
        this.configuration = configuration;
        this.executor = executor;
    }

    /**
     * 获取Mapper
     * @param calss
     * @param <T>
     * @return
     */
    public  <T> T getMapper(Class calss)
    {
       return  configuration.getMapper(calss,this);
    }

    /**
     * 实现查询功能
     * @param sql
     * @param param
     * @param <T>
     * @return
     */
    public <T> T selectone(String sql,String param,Class classType)
    {
        return  executor.query(sql,param,classType);
    }




}
